package de.dhbw.karlsruhe.picsim.gui.renderer;

import de.dhbw.karlsruhe.picsim.model.memory.FileAddress;
import de.dhbw.karlsruhe.picsim.util.impl.BitUtilities;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: goesen
 * Date: Apr 15, 2010
 * Time: 11:09:25 PM
 */
public final class FileAddressRenderer extends DefaultTableCellRenderer {
    @Override
    public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected,
                                                   final boolean hasFocus, final int row, final int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        if (value != null && value instanceof FileAddress) {
            setText(String.valueOf(BitUtilities.fromLeastSignificantBitFirst(((FileAddress) value).getBits())));
        }
        return this;
    }
}
